import router from '../router';
import { cartadd, cartedit, cartlist } from '../utils/api';

export default {
    cartlist_g(context, payload) {
        cartlist(payload).then(res=>{
            if (res.code == 200) {
                console.log(res.list)
                // this.cartlist = res.list
                context.commit('cartlist_m',res.list)
            }else{
                alert(res.msg)
                router.push('/login')
                return;
            }
        })
    },
    cartadd_g(context,payload) {
        cartadd(payload).then(res => {
            if (res.code == 200) {
                alert(res.msg)
            }
        })
    },
    cartedit_g(context, payload) {
        cartedit(payload).then(res => {
            if (res.code == 200) {
                // context.dispatch('cartlist_g',{uid:JSON.parse(localStorage.getItem('user')).uid})
            }
        })
    }
}